//
//  SRAttentionTableViewCell.m
//  Fitness
//
//  Created by SunZhongyuan on 2018/6/5.
//  Copyright © 2018年 SunZhongyuan. All rights reserved.
//

#import "SRAttentionTableViewCell.h"
#import "NoteCategoryEnum.h"

@interface SRAttentionTableViewCell ()

@property(nonatomic, strong) UIImageView *catImageView;
@property(nonatomic, strong) UIImageView *mainImageView;
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UILabel *authorLabel;
@property(nonatomic, strong) UIImageView *tagImageView;
@property(nonatomic, strong) UILabel *tagLabel;
@property(nonatomic, strong) UIImageView *dateImageView;
@property(nonatomic, strong) UILabel *dateLabel;
@property(nonatomic, strong) UIImageView *pvImageView;
@property(nonatomic, strong) UILabel *pvLabel;

@property(nonatomic,assign)CGFloat horizontalMargin;

@end

@implementation SRAttentionTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
    
        self.horizontalMargin = kScreenWidth * 0.02;
        self.backgroundColor = [UIColor colorWithHexString:@"#F4FCFF" alpha:1.0];
        
        [self addSubview:self.mainImageView];
        [self.mainImageView addSubview:self.catImageView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.authorLabel];
        [self addSubview:self.tagImageView];
        [self addSubview:self.tagLabel];
        [self addSubview:self.dateImageView];
        [self addSubview:self.dateLabel];
        [self addSubview:self.pvImageView];
        [self addSubview:self.pvLabel];
    }
    return self;
}

- (void)setNote:(SRNote *)note {
    
    switch (note.category) {
        case NoteCategoryEnumAudio: // 音频
            self.catImageView.image = [UIImage imageNamed:@"note_cat_audio"];
            break;
        case NoteCategoryEnumVideo: // 视频
            self.catImageView.image = [UIImage imageNamed:@"note_cat_video"];
            break;
        case NoteCategoryEnumArticle: // 文章
            self.catImageView.image = [UIImage imageNamed:@"note_cat_article"];
            break;
        default:
            break;
    }
    
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:note.mainUrl] placeholderImage:[UIImage imageNamed:@""]];
    self.titleLabel.text = note.title;
    self.authorLabel.text = [NSString stringWithFormat:@"作者：%@", note.author];
    self.tagLabel.text = note.tag;
    self.dateLabel.text = note.date;
    self.pvLabel.text = [NSString stringWithFormat:@"%@人学过", note.pv];
}



@end
